/*
 * GUIObject.cpp
 *
 *  Created on: 20/10/2009
 *      Author: marcos
 */

#include "GUIObject.h"
namespace gui {

int toPixels(double v) {
	return util::doubleToInt(v * METERS_TO_PIXEL_RATIO);
}

GUIObject::GUIObject() {
	this->rColor = 0;
	this->gColor = 0;
	this->bColor = 0;
	this->xPos = 0;
	this->yPos = 0;
	this->width = 1;
	this->height = 1;
	this->rotation = 0;
	this->texture = "";
	this->textureTransparentColorR = -1;
	this->textureTransparentColorG = -1;
	this->textureTransparentColorB = -1;
}

GUIObject::~GUIObject() {

}

int GUIObject::getRColor() {
	return this->rColor;
}

int GUIObject::getGColor() {
	return this->gColor;
}

int GUIObject::getBColor() {
	return this->bColor;
}

int GUIObject::getXPos() {
	return this->xPos;
}

int GUIObject::getYPos() {
	return this->yPos;
}

double GUIObject::getRotation() {
	return this->rotation;
}

int GUIObject::getHeight() {
	return this->height;
}

int GUIObject::getWidth() {
	return this->width;
}

std::string GUIObject::getTexture() {
	return this->texture;
}

int GUIObject::getTextureTransparentColorR() {
	return this->textureTransparentColorR;
}

int GUIObject::getTextureTransparentColorG() {
	return this->textureTransparentColorG;
}

int GUIObject::getTextureTransparentColorB() {
	return this->textureTransparentColorB;
}

bool GUIObject::getTextureNoRepeat() {
	return this->noRepeat;
}
bool GUIObject::getTextureHasTransparentColor() {
	return this->hasTransparentColor;
}

void GUIObject::setBGColor(int r, int g, int b) {
	this->rColor = r;
	this->gColor = g;
	this->bColor = b;
}

void GUIObject::setPosition(int x, int y) {
	this->xPos = x;
	this->yPos = y;
}

void GUIObject::setRotation(double rotation) {
	this->rotation = rotation;
}

void GUIObject::setSize(int w, int h) {
	this->width = w;
	this->height = h;
}

void GUIObject::setTexture(std::string texture, bool noRepeat) {
	this->texture = texture;
	this->noRepeat = noRepeat;
	this->hasTransparentColor = false;
}
void GUIObject::setTexture(std::string texture, int transparentColorR, int transparentColorG, int transparentColorB, bool noRepeat) {
	this->texture = texture;
	this->noRepeat = noRepeat;
	this->hasTransparentColor = true;
	this->textureTransparentColorR = transparentColorR;
	this->textureTransparentColorG = transparentColorG;
	this->textureTransparentColorB = transparentColorB;
}
/* Recibe metros */
void GUIObject::setCenterInMeters(double x, double y) {
	this->setPosition(toPixels(x), toPixels(y));
}
void GUIObject::setSizeInMeters(double w, double h) {
	this->setSize(toPixels(w), toPixels(h));
}

}
